package org.prem.springmvc.hello;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloControllerPathVariable{
	
	@RequestMapping("/hellocontrollerpathvariable/{country}/{username}")
	public ModelAndView helloWorld(@PathVariable("username") String name, @PathVariable("country") String country){
		ModelAndView modelAndView = new ModelAndView("HelloWelcome");
		modelAndView.addObject("msg", "hello "+name+",your country is "+country);
		return modelAndView;
	}

	@RequestMapping("/hellocontrollerpathvariables/{country}/{username}")
	public ModelAndView helloWorld(@PathVariable Map<String,String> pathVarMap){
		String name = pathVarMap.get("username");
		String country = pathVarMap.get("country");
		ModelAndView modelAndView = new ModelAndView("HelloWelcome");
		modelAndView.addObject("msg", "hello "+name+",your country is "+country);
		return modelAndView;
	}
}
